<?PHP
	require 'includes/master.inc.php';

	$app = new App($_GET['app_id']);
	if($app->id == "") die("Application not found.");

	$ip = $_SERVER['REMOTE_ADDR'];
	$dt = date("Y-m-d H:i:s");

	if(count($_GET) < 2)
		$db->query("INSERT INTO sparkle (ip, dt, is_blank) VALUES ('$ip', '$dt', 1)");
	else
	{
		$os      = isset($_GET['osVersion']) ? mysql_real_escape_string($_GET['osVersion']) : '';
		$cpu     = isset($_GET['cputype']) ? mysql_real_escape_string($_GET['cputype']) : '';
		$cpusub  = isset($_GET['cpusubtype']) ? mysql_real_escape_string($_GET['cpusubtype']) : '';
		$model   = isset($_GET['model']) ? mysql_real_escape_string($_GET['model']) : '';
		$ncpu    = isset($_GET['ncpu']) ? mysql_real_escape_string($_GET['ncpu']) : '';
		$lang    = isset($_GET['lang']) ? mysql_real_escape_string($_GET['lang']) : '';
		$appName = isset($_GET['appName']) ? mysql_real_escape_string($_GET['appName']) : '';
		$version = isset($_GET['appVersion']) ? mysql_real_escape_string($_GET['appVersion']) : '';
		$freq    = isset($_GET['cpuFreqMHz']) ? mysql_real_escape_string($_GET['cpuFreqMHz']) : '';
		$ram     = isset($_GET['ramMB']) ? mysql_real_escape_string($_GET['ramMB']) : '';
		$db->query("INSERT INTO sparkle (osVersion, cpuType, cpusubtype, model, ncpu, lang, appName, appVersion, cpuFreqMHz, ramMB, ip, dt, is_blank) VALUES ('$os', '$cpu', '$cpusub', '$model', '$ncpu', '$lang', '$appName', '$version', '$freq', '$ram', '$ip', '$dt', 0)");
	}

	header("Content-type: application/xml");
	echo $app->feed();
